package test;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author bll
 * @version 1.0
 * @date 2025/3/19 14:31
 */
class solution {
    static List<List<Integer>> result = new ArrayList<>();
    static List<Integer> path = new ArrayList<>();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[][] graph = new int[n + 1][m + 1];//初始化邻接矩阵

        while (m-- > 0) {
            int i = scanner.nextInt();
            int j = scanner.nextInt();
            graph[i][j] = 1;//接收变量
        }
        path.add(1);
        dfs(graph, 1, n);
        if (result.size() == n) {
            System.out.println(-1);
        }
        for (int i = 0; i < result.size(); i++) {
            for (int j = 0; j < result.get(i).size(); j++) {
                System.out.print(result.get(i).get(j) + " ");
            }
        }
    }

    static void dfs(int[][] graph, int x, int n) {
        if (x == n) {
            result.add(new ArrayList<>(path));
            return;
        }
        for (int i = 0; i < graph.length; i++) {
            if (graph[x][i] == 1) {
                path.add(i);
                dfs(graph, i, n);
                path.remove(path.size() - 1);
            }
        }
    }
}
